home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / src / editors / AME / Rexx / vprefs.ame < prev    next >
Encoding:
Text File  |  1994-02-01  |  5.9 KB  |  232 lines

  1. /* $VER: VPrefs 37.1 (21.2.93) */
  2. /*This program brings up a Preferences Requester for AME */
  3.  
  4. if show("l", "rexxarplib.library") = 0 then do
  5.    check = addlib('rexxsupport.library', 0, -30, 0)
  6.    check = addlib('rexxarplib.library',  0, -30, 0)
  7. end
  8.  
  9. options results
  10.  
  11. /*
  12. *   The following sequence determines both AME's screen and port name,
  13. *   and also gets the number screen rows and columns.
  14. */
  15.  
  16. ameport = address()
  17. cols = ScreenCols(ameport)
  18. if cols == -1 then do
  19.    amescreen = ""
  20.    cols = ScreenCols()
  21.    rows = ScreenRows()
  22. end
  23. else do
  24.    amescreen = ameport
  25.    rows = ScreenRows(amescreen)
  26. end
  27. /*
  28.  *   Set up a host. This time, send all messages to our own port.
  29.  */
  30.  
  31. address AREXX "'x = CreateHost(AMEPREFS, PREFSPORT, "amescreen")'"
  32. /*
  33.  *   Wait until it is ready.
  34.  */
  35. do i = 1
  36.    if showlist('p', AMEPREFS) ~= 0 then leave
  37.    call delay 30
  38. end
  39.  
  40. /*
  41.  *   Open the window
  42.  */
  43.  
  44. idcmp = 'CLOSEWINDOW+GADGETUP'
  45. flags = 'WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH+ACTIVATE'
  46.  
  47. call OpenWindow(AMEPREFS, 0, 0, 640, 200, idcmp,   ,
  48.                 flags, "AME Preferences...")
  49.  
  50. /*
  51.  *   Open the port that messages will come to
  52.  */
  53. mp = openport(PREFSPORT)
  54.  
  55.  
  56. /*   Read the current settings */
  57. template = "AUTORD BACKUP BEEP CASE EOL FOLDS FREQ ICONS REGEX REQ UNDO"
  58. parse var template v.1 v.2 v.3 v.4 v.5 v.6 v.7 v.8 v.9 v.10 v.11
  59. 'getprefs' template
  60. parse var result p.1 p.2 p.3 p.4 p.5 p.6 p.7 p.8 p.9 p.10 p.11 .
  61.  
  62. template = "CHECK COLOR CONWAIT INDENT LEFT MCOLOR RIGHT TAB USTEPS"
  63. parse var template v.12 v.13 v.14 v.15 v.16 v.17 v.18 v.19 v.20
  64. 'getprefs' template
  65. parse var result x p.12 x p.13 x p.14 x p.15 x p.16 x p.17 x p.18 x p.19 x p.20 .
  66.  
  67. template = "ADDRESS PROJECT RXCON EPORT"
  68. parse var template v.21 v.22 v.23 v.24
  69. 'getprefs' template
  70. parse var result 'ADDRESS: ' p.21 'PROJECT: ' p.22 'RXCON: ' p.23 'EPORT: ' p.24 .
  71.  
  72. /*
  73.  *   Add the gadgets
  74.  */
  75.  
  76. call AddGadget(AMEPREFS, 50,  18, 1, "  ", "%d")
  77. call AddGadget(AMEPREFS, 50,  36, 2, "  ", "%d")
  78. call AddGadget(AMEPREFS, 50,  54, 3, "  ", "%d")
  79.  
  80. call AddGadget(AMEPREFS, 200,  18, 4, "  ", "%d")
  81. call AddGadget(AMEPREFS, 200,  36, 5, "  ", "%d")
  82. call AddGadget(AMEPREFS, 200,  54, 6, "  ", "%d")
  83.  
  84. call AddGadget(AMEPREFS, 350,  18, 7, "  ", "%d")
  85. call AddGadget(AMEPREFS, 350,  36, 8, "  ", "%d")
  86. call AddGadget(AMEPREFS, 350,  54, 9, "  ", "%d")
  87.  
  88. call AddGadget(AMEPREFS, 500,  18, 10, "  ", "%d")
  89. call AddGadget(AMEPREFS, 500,  36, 11, "  ", "%d")
  90. call AddGadget(AMEPREFS, 500,  54, 20, p.20, "%d%1%g",48,RIDGEBORDER)
  91.  
  92. Call Move(AMEPREFS,80,24)
  93. Call Text(AMEPREFS,"Auto Read")
  94. Call Move(AMEPREFS,80,42)
  95. Call Text(AMEPREFS,"Backup")
  96. Call Move(AMEPREFS,80,60)
  97. Call Text(AMEPREFS,"Beep")
  98.  
  99. Call Move(AMEPREFS,230,24)
  100. Call Text(AMEPREFS,"Case")
  101. Call Move(AMEPREFS,230,42)
  102. Call Text(AMEPREFS,"EOL Track")
  103. Call Move(AMEPREFS,230,60)
  104. Call Text(AMEPREFS,"Folds")
  105.  
  106. Call Move(AMEPREFS,380,24)
  107. Call Text(AMEPREFS,"File Req")
  108. Call Move(AMEPREFS,380,42)
  109. Call Text(AMEPREFS,"Icons")
  110. Call Move(AMEPREFS,380,60)
  111. Call Text(AMEPREFS,"Regex")
  112.  
  113. Call Move(AMEPREFS,530,24)
  114. Call Text(AMEPREFS,"Req")
  115. Call Move(AMEPREFS,530,42)
  116. Call Text(AMEPREFS,"Undo")
  117. Call Move(AMEPREFS,554,60)
  118. Call Text(AMEPREFS,"USteps")
  119.  
  120. call AddGadget(AMEPREFS, 50,  80, 12, p.12, "%d%1%g",48,RIDGEBORDER)
  121. call AddGadget(AMEPREFS, 50,  98, 13, p.13, "%d%1%g",48,RIDGEBORDER)
  122.  
  123. call AddGadget(AMEPREFS, 200,  80, 14, p.14, "%d%1%g",48,RIDGEBORDER)
  124. call AddGadget(AMEPREFS, 200,  98, 15, p.15, "%d%1%g",48,RIDGEBORDER)
  125.  
  126. call AddGadget(AMEPREFS, 350,  80, 16, p.16, "%d%1%g",48,RIDGEBORDER)
  127. call AddGadget(AMEPREFS, 350,  98, 17, p.17, "%d%1%g",48,RIDGEBORDER)
  128.  
  129. call AddGadget(AMEPREFS, 500,  80, 18, p.18, "%d%1%g",48,RIDGEBORDER)
  130. call AddGadget(AMEPREFS, 500,  98, 19, p.19, "%d%1%g",48,RIDGEBORDER)
  131.  
  132. Call Move(AMEPREFS,104,86)
  133. Call Text(AMEPREFS,"Check")
  134. Call Move(AMEPREFS,104,104)
  135. Call Text(AMEPREFS,"Color")
  136.  
  137. Call Move(AMEPREFS,254,86)
  138. Call Text(AMEPREFS,"Conwait")
  139. Call Move(AMEPREFS,254,104)
  140. Call Text(AMEPREFS,"Indent")
  141.  
  142. Call Move(AMEPREFS,404,86)
  143. Call Text(AMEPREFS,"Left")
  144. Call Move(AMEPREFS,404,104)
  145. Call Text(AMEPREFS,"Mcolor")
  146.  
  147. Call Move(AMEPREFS,554,86)
  148. Call Text(AMEPREFS,"Right")
  149. Call Move(AMEPREFS,554,104)
  150. Call Text(AMEPREFS,"Tab")
  151.  
  152. call AddGadget(AMEPREFS, 50,  126, 21, p.21, "%d%1%g",120,RIDGEBORDER)
  153. call AddGadget(AMEPREFS, 50,  144, 22, p.22, "%d%1%g",120,RIDGEBORDER)
  154.  
  155. call AddGadget(AMEPREFS, 350,  126, 23, p.23, "%d%1%g",120,RIDGEBORDER)
  156. call AddGadget(AMEPREFS, 350,  144, 24, p.24, "%d%1%g",120,RIDGEBORDER)
  157.  
  158. Call Move(AMEPREFS,176,132)
  159. Call Text(AMEPREFS,"Address")
  160. Call Move(AMEPREFS,176,150)
  161. Call Text(AMEPREFS,"Project")
  162.  
  163. Call Move(AMEPREFS,476,132)
  164. Call Text(AMEPREFS,"RXCON")
  165. Call Move(AMEPREFS,476,150)
  166. Call Text(AMEPREFS,"EPORT")
  167.  
  168. call AddGadget(AMEPREFS, 50, 180, "USE",   "  OK    ", "USE")
  169. call AddGadget(AMEPREFS,500, 180, "CLOSE", " Cancel ", "CANCEL")
  170.  
  171. /*
  172.  *   set gadgets that should be on
  173.  */
  174.  
  175. do i = 1 to 11
  176.     if(left(p.i,1,1)= 'N') then do
  177.     res = SetGadget(AMEPREFS, i, "OFF")
  178.     end
  179.     else do
  180.     res = SetGadget(AMEPREFS, i, "ON")
  181.         end
  182.     end
  183.  
  184. /*
  185.  *   Main event loop
  186.  */
  187. quitflag  = 0
  188.  
  189. do forever
  190.    if quitflag = 1 then leave
  191.    t = waitpkt(PREFSPORT)
  192.    do forever
  193.       p = getpkt(PREFSPORT)
  194.       if c2d(p) = 0 then leave
  195.       cmd = getarg(p)
  196.       if cmd > 11 then stringarg = getarg(p,1)
  197.       t = reply(p, 0)
  198.  
  199.       /* see what we got */
  200.       if cmd = "CANCEL" then do
  201.          call CloseWindow(AMEPREFS)
  202.          quitflag = 1
  203.          end
  204.       else if cmd = "USE" | cmd = "CLOSEWINDOW" then do
  205.          call CloseWindow(AMEPREFS)
  206.      do i = 1 to 11
  207.          if left(p.i,1,1) = 'N' then 'unsetprefs' v.i
  208.          else 'setprefs' v.i
  209.          end
  210.      temp = ""
  211.      do i = 12 to 24
  212.          temp = temp || v.i '"' || p.i || '"'
  213.          end
  214.      'setprefs' temp
  215.          quitflag = 1
  216.          end
  217.       else if datatype(cmd, 'W') = 1 then do
  218.       if cmd < 12 then do
  219.          if left(p.cmd,1,1) = 'N' then do
  220.         call SetGadget(AMEPREFS, cmd, "ON")
  221.         p.cmd = 'O'
  222.         end
  223.          else do
  224.         call SetGadget(AMEPREFS, cmd, "OFF")
  225.         p.cmd = 'N'
  226.           end
  227.              end
  228.       else p.cmd = stringarg
  229.       end
  230.       end
  231.     end
  232. exit